<?php


   class TestAction extends Action{
   
      public function index(){
  /*     
	 $a='你19啊你15啊你16啊';
     $b=preg_match_all('/\d+/',$a,$arr);
     print_r($arr);*/
	 
	 
	 $shijian= date(H);
	   
	 if($shijian>$system['kaishi'] and $shijian<$system['jieshu']){
	 
	     $isquannei=M('quannei')->where('openid="%s"',session('openid'))->find();
		 
		 if($isquannei==null){
		 
		 
		   $this->redirect('Index/shenhe');
		   
		   exit();
		 
		 }
	 
	 
	 }  
	            
   
   
     }
	 
	 
	 public function ceshi(){
	 
	   echo "1111";
	 
	 }
	 
	 
	 public function fatu(){
	 
	 
	 /*   $url="http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=aTH0Yj0odg7y9JK53SQus3SyMe2IxoDe_tXUhzyFDtVO5KbFdOja1tnUJVZKOYVniPFDn3Lp28rWG3SSmxFKQ9hPaEm-uHm2Kilj_BDOR9UGAexV_1LeZoauZVHGItpJNNMhADATTS&type=image";
				$file = realpath("./images/blur-3.gif"); //要上传的文件
				$fields['media'] = '@'.$file;
				$ch = curl_init($url) ;
				curl_setopt($ch, CURLOPT_POST, 1);
				curl_setopt($ch, CURLOPT_POSTFIELDS,$fields);
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
				$myimg = curl_exec($ch);
				if (curl_errno($ch)) {
				 return curl_error($ch);
				}
				curl_close($ch);				
				$myimg=json_decode($myimg,true);*/

				 //客户消息回复图片
				$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=aTH0Yj0odg7y9JK53SQus3SyMe2IxoDe_tXUhzyFDtVO5KbFdOja1tnUJVZKOYVniPFDn3Lp28rWG3SSmxFKQ9hPaEm-uHm2Kilj_BDOR9UGAexV_1LeZoauZVHGItpJNNMhADATTS";
                $data = '{
                          "touser":"gh_146752b608ad",
                          "msgtype":"text",
                                    "text":
						{
							 "content":"Hello World"
						}
					}';
                $this->https_request($url,$data);
	 
	 
	 
	 }
	 
	   public function https_request($url, $data = null)
    {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
        if (!empty($data)){
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        }
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return $output;
    }
	 
	 
	 
	 public function jieshou(){
	    
		$re = $this->pic64('1.jpg');
           //验证图片级别
        $picinfo = $this->picyanzheng($re);
		
		dump($picinfo);
		
	 }
	 
	 
	 
	 public function xiaoxi(){
	 
	 	
			
				
				$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=4-ZBJSi-PeMK5i7mSrSGdUaauEbsc3TaSHMZJaBFLi_BE4C5tNvJ4HtJYwO9LDmd6H8d9iCjH9GpZ56z-gaqmKKNf6nkg-09bDtUMBGmNHYa1hS6XOEb6Pwn8MXYScrzLBWeADADTO";
                $data = '{
                    "touser": "o96UCwSL6bu5MzS_R0IwYTqr2yi8", 
                    "msgtype": "text", 
                    "text": {
                        "content": "请稍123后，我们正在努力处理中"
                    }
                }';
                $re=$this->https_request($url,$data);
               
			   dump($re);
	        
	 
	 
	 }
	 
	 
	 public function ishave(){
	 
		 $str="【欧洲站女鞋2017春季新款单鞋厚底松糕鞋白色一脚蹬乐福鞋女懒人鞋】http://c.b1wt.com/h.VE7D7M?cv=0ymOo4QHhH&sm=ef7188 点击链接，再选择浏览器打开；或复制这条信息，打开手机淘宝￥0ymOo4QHhH￥";
		 
		 $re= strstr($str, '】');
		 
		// dump($re);
		 
		 $result=str_replace(array("【","$re"),"",$str);
		 
		 echo $result;
		 
		 //$need=$this->getNeedBetween($str, '【' , '】' );
		 
		// echo $need;
		 
		 if($re){
		   
		   echo "1";
		 
		  }else{
		 
		   echo "2";
		 
		 }
	 
	 }
	 
	public  function getNeedBetween($kw1,$mark1,$mark2){
		$kw=$kw1;
		$kw='123'.$kw.'123';
		$st =stripos($kw,$mark1);
		$ed =stripos($kw,$mark2);
		if(($st==false||$ed==false)||$st>=$ed)
		return 0;
		$kw=substr($kw,($st+1),($ed-$st-1));
		return $kw;
		}
	 
	 
   }